<?php
/*
	
*/
defined('BY_JYA') or exit('Access Denied');
global $_RQ,$_AR;

$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
$setting=$this->plugin_setting('basic');
$return['banner']=$setting['hdps'];
$return['setting']=$setting;
if($_RQ['op']=='main'){
	cfc('core')->checklogin();
	exi($return);
}
/*******op*******/
if($_RQ['op']=='list'){
	//查询进入该页面的客户所有订单
	$params=array('mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid'],'issub'=>1);
	if($_RQ['id']){
		$params['datiid']=$_RQ['id'];
		$returnparams['datiid']=$_RQ['id'];
	}
	if(isset($_RQ['status'])&& $_RQ['status'] != 10){
		$params['status']=intval($_RQ['status']);
		$return['status']=$_RQ['status'];
	}else{
		$return['status']=10;
	}
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total='';
	$list=pdo_getslice('jy_lineks_canyu',$params,array($pindex,$psize),$total,$fields,'','endtime desc');
	if($list){
		foreach($list as &$item){
			$activity=pdo_get('jy_lineks_list',array('id'=>$item['datiid'],'uniacid'=>$_SESSION['uniacid']));
			$item['activity']=$activity;
			$item['title']=$activity['title'];
			if($item['endtime']){
				$item['istime']=$item['endtime']-$item['starttime'];
			}
			if($item['istime']>60){
				$item['istimefen']=intval($item['istime']/60);
				$item['istimemin']=$item['istime']-$item['istimefen']*60;
			}else{
				$item['istimefen']=0;
				$item['istimemin']=$item['istime'];
			}
			$item['starttime']=$item['starttime']?:$item['createtime'];
			$item['starttime']=date('Y-m-d H:i:s', $item['starttime']);
			$item['endtime']=date('Y-m-d H:i:s', $item['endtime']);
		}
	}
	$return['list']=$list;
	exi($return);
}
//订单详情
if($_RQ['op']=='detail'){
	if(!$_RQ['id']){
	exi('订单不存在，请重新选择','error');
	}
	$order=pdo_get('jy_lineks_canyu',array('uniacid'=>$_SESSION['uniacid'],'id'=>$_RQ['id']));
	//用户信息
	$member=pdo_get('core_members',array('uniacid'=>$_SESSION['uniacid'],'id'=>$order['mid']));
	//活动信息
	$item=pdo_get('jy_lineks_list',array('uniacid'=>$_SESSION['uniacid'],'id'=>$order['datiid']));	
	$order['content']=json_decode($order['content'],true);
	$return['order']=$order;
	$return['member']=$member;
	$return['item']=$item;
	exi($return);
}